package com.sky.controller.user;

import com.sky.pojo.Merchant;
import com.sky.result.Result;
import com.sky.service.user.MerchantService;
import com.sky.vo.ShopVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
@Api
public class ShopController {

    public static final String key="SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private MerchantService merchantService;

    @GetMapping("/status")
    public Result<Object> findUserStatus(){
        Object status = redisTemplate.opsForValue().get(key);
        return Result.success(status);
    }

    //  获取店铺电话
    @GetMapping("/getMerchantInfo")
    @ApiOperation("获取商家信息")
    public Result   getMerchantInfo(){
        //  获取唯一商家对象信息
        Merchant merchant = merchantService.getShopById(1L);
        String  shopName = merchant.getShopName();
        String  shopAddress = merchant.getShopAddress();
        String  shopTelephone = merchant.getShopTelephone();
        ShopVO build = ShopVO.builder().phone(shopTelephone).shopName(shopName).shopAddress(shopAddress).build();
        return  Result.success(build);
    }
}
